<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="bjui-pageContent">
	
	<c:if test="${empty info.id}">
	<form action="<%=request.getContextPath()%>/tea/ratings/insert.do" data-toggle="validate" data-reload-navtab="true">
	</c:if>
	<c:if test="${not empty info.id}">
	<form action="<%=request.getContextPath()%>/tea/ratings/update.do" data-toggle="validate" data-reload-navtab="true">
		<input type="hidden" name="id" value="${info.id}">
	</c:if>
		<input type="hidden" name="foods.id" value="${foodsId}">
        <div class="pageFormContent" data-layout-h="0">
            <table class="table table-condensed table-hover" width="100%">
                <tbody>
                	<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">用户名：</label>
	                        <input type="text" name="username" value="${info.username}" size="60">
	                    </td>
		    		</tr>
           			<tr>
				 		<td colspan="2">
                        	<label class="control-label x100">头像：</label>
	                    	<div style="display:inline-block; vertical-align:middle;">
						    	<div id="avatar_pic_up" data-toggle="upload" data-uploader="<%=request.getContextPath()%>/tea/ratings/springUpload.do"
							        data-file-size-limit="1024000000"
							        data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
							        data-multi="true"
							        data-on-upload-success="avatar_upload_success"
							        data-icon="cloud-upload"></div>
							    <input type="hidden" name="avatar" value="${info.avatar}" id="avatar_pic">
							</div>
							<span id="avatar_span_pic">
								<c:if test="${not empty info.avatar}">
								已上传图片：<img width="50" height="50" src="<%=request.getContextPath()%>/${info.avatar}">
								</c:if>
							</span>
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">类型：</label>
	                        <select name="rateType" data-toggle="selectpicker" data-width="200" id="rateType">
                        		<option value="1" <c:if test="${info.rateType == 1}">selected="selected"</c:if> >赞</option>
	                        	<option value="0" <c:if test="${info.rateType == 0}">selected="selected"</c:if> >踩</option>
	                        </select>
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">内容：</label>
	                        <input type="text" name="text" value="${info.text}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">时间：</label>
	                        <input type="text" name="rateTime" value="${info.rateTime}" size="60">
	                    </td>
		    		</tr>
                </tbody>
            </table>
        </div>
    </form>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
        <li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
    </ul>
</div>
<script type="text/javascript">
    function avatar_upload_success(file, data) {
        var json = $.parseJSON(data);
        $(this).bjuiajax('ajaxDone', json);
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $('#avatar_pic').val(json.filename);
            $('#avatar_span_pic').html('已上传图片：<img width="50" height="50" src="<%=request.getContextPath()%>/'+json.filename +'">');
        }
    }
</script>